﻿using System;
using System.Collections.Generic;
using System.Text;

namespace FySystem.FyAppConfig
{
    public class FyAppConfigManager
    {
        /// <summary>
        /// 所有的配置项
        /// </summary>
        private static FyConfigs _config = null;

        private static FyAppConfigManager _cfg = new FyAppConfigManager();

        public static FyAppConfigManager Appconfigs { get; } = _cfg;

        /// <summary>
        /// 构造
        /// </summary>
        private FyAppConfigManager()
        {
            try
            {
                _config = new FyConfigs("configs.txt");
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// 获取配置值
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public string this[string key]
        {
            get
            {
                string res = string.Empty;
                if (_config.Configs.ContainsKey(key))
                    res = _config.Configs[key];
                return res;
            }
        }
    }
}
